package com.itheima.user.controller;


import com.github.xiaoymin.knife4j.annotations.DynamicParameter;
import com.github.xiaoymin.knife4j.annotations.DynamicParameters;
import com.itheima.common.vo.PageResultVo;
import com.itheima.common.vo.ResultVo;
import com.itheima.core.controller.AbstractCoreController;
import com.itheima.user.dto.ApUserRealnamePageRequestDto;
import com.itheima.user.pojo.ApUserRealname;
import com.itheima.user.service.ApUserRealnameService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @description <p>APP实名认证信息</p>
 *
 * @version 1.0
 * @package com.itheima.user.controller
 */
@Api(value="ApUserRealnameController",tags = "APP实名认证信息")
@RestController
@RequestMapping("/auth")
public class ApUserRealnameController extends AbstractCoreController<ApUserRealname> {

    private ApUserRealnameService apUserRealnameService;

    @Autowired
    public ApUserRealnameController(ApUserRealnameService apUserRealnameService) {
        super(apUserRealnameService);
        this.apUserRealnameService=apUserRealnameService;
    }

    @ApiOperation("APP实名认证分页搜索")
    @PostMapping("/list")
    public PageResultVo list(@RequestBody ApUserRealnamePageRequestDto dto) {
        PageResultVo pageResultVo = apUserRealnameService.pageList(dto);
        return pageResultVo;
    }

    @PostMapping("/authFail")
    @ApiOperation("实名认证审核驳回")
    @DynamicParameters(
            name = "paramMap",
            properties = {
                    @DynamicParameter(name = "id", required = true,value = "实名认证id", dataTypeClass = Integer.class),
                    @DynamicParameter(name = "msg", required = true,value = "原因", dataTypeClass = String.class)
            }
    )
    public ResultVo authFail(@RequestBody Map<String,Object> map){
        apUserRealnameService.authFail(map);
        return ResultVo.ok();
    }


    @PostMapping("//authPass")
    @ApiOperation("实名认证审核通过")
    @DynamicParameters(
            name = "paramMap",
            properties = {
                    @DynamicParameter(name = "id", required = true,value = "实名认证id", dataTypeClass = Integer.class),
                    @DynamicParameter(name = "msg", required = true,value = "原因", dataTypeClass = String.class)
            }
    )
    public ResultVo authPass(@RequestBody Map<String,Object> map){
        apUserRealnameService.authPass(map);
        return ResultVo.ok();
    }


}

